package cn.com.headfree.mouldshow.dao.impl;

import cn.com.headfree.entity.TRotationInfoTemp;
import cn.com.headfree.mouldshow.dao.TRotationInfoTempDao;
import com.gta.edu.sdk.base.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository;

import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Repository("/tRotationInfoTempDaoImpl")
public class TRotationInfoTempDaoImpl extends BaseDaoImpl<TRotationInfoTemp> implements TRotationInfoTempDao {


    @Override
    public void saveInfo(TRotationInfoTemp tRotationInfoTemp) {
        String sql = "insert into t_rotation_info_temp (id,erp_no,user_name,rotation_dept,rotation_org,rotation_post,start_time,end_time,org_id,creater_id,creater_name,create_time,updater_id,updater_name,update_time,del_sign,is_valid,audit_state,orignal_id,business_type_id,primitive_id) values ";
        StringBuilder sqlBuilder = new StringBuilder(sql);
        sqlBuilder.append("(#{id,jdbcType=VARCHAR},").append("#{erp_no,jdbcType=VARCHAR},").append("#{user_name,jdbcType=VARCHAR},")
                .append("#{rotation_dept,jdbcType=VARCHAR},").append("#{rotation_org,jdbcType=INTEGER},")
                .append("#{rotation_post,jdbcType=VARCHAR},").append("#{start_time,jdbcType=DATE},")
                .append("#{end_time,jdbcType=DATE},").append("#{org_id,jdbcType=VARCHAR},").append("#{creater_id,jdbcType=VARCHAR},")
                .append("#{creater_name,jdbcType=DATE},").append("#{create_time,jdbcType=DATE},")
                .append("#{updater_id,jdbcType=VARCHAR},").append("#{updater_name,jdbcType=VARCHAR},")
                .append("#{update_time,jdbcType=DATE},").append("#{del_sign,jdbcType=INTEGER},")
                .append("#{is_valid,jdbcType=INTEGER},").append("#{audit_state,jdbcType=INTEGER},")
                .append("#{orignal_id,jdbcType=VARCHAR},").append("#{business_type_id,jdbcType=VARCHAR},")
                .append("#{primitive_id,jdbcType=VARCHAR})");
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("id", tRotationInfoTemp.getId());
        params.put("erp_no", tRotationInfoTemp.getErpNo());
        params.put("user_name", tRotationInfoTemp.getUserName());
        params.put("rotation_dept", tRotationInfoTemp.getRotationDept());
        params.put("rotation_org", tRotationInfoTemp.getRotationOrg());
        params.put("rotation_post", tRotationInfoTemp.getRotationPost());
        params.put("start_time", tRotationInfoTemp.getStartTime());
        params.put("end_time", tRotationInfoTemp.getEndTime());
        params.put("org_id", tRotationInfoTemp.getOrgId());
        params.put("creater_id", tRotationInfoTemp.getCreaterId());
        params.put("creater_name", tRotationInfoTemp.getCreaterName());
        params.put("create_time", new Timestamp(new Date().getTime()));
        params.put("updater_id", tRotationInfoTemp.getUpdaterId());
        params.put("updater_name", tRotationInfoTemp.getUpdaterName());
        params.put("update_time", new Timestamp(new Date().getTime()));
        params.put("del_sign", 0);
        params.put("is_valid", tRotationInfoTemp.getIsValid());
        params.put("audit_state", tRotationInfoTemp.getAuditState());
        params.put("orignal_id", tRotationInfoTemp.getOrignalId());
        params.put("business_type_id", tRotationInfoTemp.getBusinessTypeId());
        params.put("primitive_id", tRotationInfoTemp.getPrimitiveId());
        this.executeSql(sqlBuilder.toString(), params);
    }
}
